package demo2;

public class LeetCodeLCR179 {
    public int[] twoSum(int[] arr, int target) {
        int[] nums = new int[2];
        int left = 0, right = arr.length - 1;
        while (left < right) {
            if (arr[left] + arr[right] < target) left++;
            else if (arr[left] + arr[right] > target) right--;
            else  {
                nums[0] = arr[left];
                nums[1] = arr[right];
                return nums;
            }
        }
        return nums;
    }
}
